<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../jquery/jquery-1.12.4.min.js"></script>
    <style>
        div {
            width: 600px;
            height: 400px;
            border: 1px solid red;
            margin: 20px auto;
        }

        img {
            display: inline-block;
            width: 250px;
            height: 400px;
        }
    </style>
</head>

<body>
    <button class="submit">点击</button>
    <div>

    </div>
    <script>

        let promise = new Promise((resolve, reject) => {
            $.ajax({
                method: "get",
                url: 'http://localhost:3000/testdata',
                data: {

                },
                success: (data) => {
                    resolve(data);
                },
                error: err => {
                    reject(err);
                }
            })
        })
        let divinner = "";
        
        
        $('.submit').on('click', async () => {
            let result = await promise;
            console.log(result);
            console.log(result.data[0].src);
            $.each(result.data,(index)=>{
                divinner += `
                    <img src=${result.data[index].src} alt="">
                `;
            })
            $('div').html(divinner)
        })
    </script>
</body>

</html>